﻿$(document).on("pageInit", "#create-cource-notice", function (e, id, page) {
    $(page).find("[name=cource-notice-create-form]").on("submit", function (evt) {
        evt.preventDefault();
        $(page).find("[name=cource-notice-create-form]").ajaxSubmit({
            success: function (response) {
                if (response.indexOf("err:") > -1) {
                    $.toast(response.substr(4));
                    return false;
                }
                history.back();
            }
        });
    });

    loadCourceList();
    function loadCourceList() {
        $.getJSON("/CourceNotice/GetCourceList", {}, function (response) {
            var $CourceId = $(page).find('[name="CourceId"]');
            $CourceId.empty();
            if (response.length > 0) {
                $.each(response, function (rIndex, rItem) {
                    $CourceId.append("<option value='" + rItem.CourceId + "'>" + rItem.CourceName + "</option>");
                });
            }
        });
    }
});